import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  Nyt7InsuranceProductVO,
  Nyt7InsuranceProductForm,
  Nyt7InsuranceProductQuery,
  Nyt7InsuranceProduct
} from '@/api/Nyt7InsuranceProduct/Nyt7InsuranceProduct/types';

/**
 * 查询保险产品列表
 * @param query
 * @returns {*}
 */

export const listNyt7InsuranceProduct = (query?: Nyt7InsuranceProductQuery): AxiosPromise<Nyt7InsuranceProductVO[]> => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询保险产品详细
 * @param id
 */
export const getNyt7InsuranceProduct = (id: string | number): AxiosPromise<Nyt7InsuranceProduct> => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/' + id,
    method: 'get'
  });
};

/**
 * 新增保险产品
 * @param data
 */
export const addNyt7InsuranceProduct = (data: Nyt7InsuranceProductForm) => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct',
    method: 'post',
    data: data
  });
};

/**
 * 修改保险产品
 * @param data
 */
export const updateNyt7InsuranceProduct = (data: Nyt7InsuranceProductForm) => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct',
    method: 'put',
    data: data
  });
};

/**
 * 删除保险产品
 * @param id
 */
export const delNyt7InsuranceProduct = (id: string | number | Array<string | number>) => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/' + id,
    method: 'delete'
  });
};


export function getProductCount() {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/count',
    method: 'get'
  });
}
/**
 * 添加导入Excel的方法
 * @param file
 */
export const importExcel = (file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};



/**
 * 导出选中的保险产品列表
 * @param ids
 */
export const exportSelected = (ids: number[]): AxiosPromise<Blob> => {
  return request({
    url: '/Nyt7InsuranceProduct/Nyt7InsuranceProduct/exportSelected',
    method: 'post',
    data: ids,
    responseType: 'blob'
  });
};
